package com.core.contant;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by dawn on 2017/11/16.
 */
public enum DataTypeEnum {

        OTHER(0), //未知
        BOOLEAN(1), // bool
        INTEGER(2), // int
        STRING(4); // string

        private static Logger logger = LoggerFactory.getLogger(DataTypeEnum.class);

        private final int value;

        DataTypeEnum(int value) {
            this.value = value;
        }

        public static DataTypeEnum fromValue(int value) {
            for (DataTypeEnum type : DataTypeEnum.values()) {
                if (type.value == value)
                    return type;
            }
            logger.error(String.format("cannot find enum, value is {0}", value));
            return null;
        }

        public int value() {
            return value;
        }
    }
